package com.seres.data;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;


public class HibernateUtil {
	private static final SessionFactory sessionFactory;
	private static ServiceRegistry serviceRegistry;
	
	static {
	try {
	    Configuration configuration = new Configuration();
	    configuration.configure("com/seres/data/seres.cfg.xml");
	    serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();        
	    sessionFactory = configuration.buildSessionFactory(serviceRegistry);
//		sessionFactory = new Configuration().configure("com/seres/data/seres.cfg.xml").buildSessionFactory();
	} catch (Throwable ex) {
		System.err.println("Initial SessionFactory creation failed." + ex);
		throw new ExceptionInInitializerError(ex);
	}
	}
	 
	public static SessionFactory getSessionFactory() {
		return sessionFactory;
	}
}
